﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QuanLyGiaoVuDAL.DTO;
using AutoMapper;

namespace QuanLyGiaoVuUI.Models.GiangVien
{
    public class BanTinGiangVienViewModel
    {
        public Guid ID { get; set; }
        public String TieuDe { get; set; }
        public String NoiDung { get; set; }
        public DateTime NgayThem { get; set; }
        public int QuyenTruyCap { get; set; }

        public BanTinDTO ToLopBanTinDTO()
        {
            Mapper.CreateMap(typeof(BanTinGiangVienViewModel), typeof(BanTinDTO));
            var banTinDTO = new BanTinDTO();
            Mapper.Map(this, banTinDTO);
            return banTinDTO;
        }

        public static BanTinGiangVienViewModel FromBanTinDTO(BanTinDTO banTinDTO)
        {
            Mapper.CreateMap(typeof(BanTinDTO), typeof(BanTinGiangVienViewModel));
            var banTinGiangVienViewModel = new BanTinGiangVienViewModel();
            Mapper.Map(banTinDTO, banTinGiangVienViewModel);
            return banTinGiangVienViewModel;
        }
        public static IEnumerable<BanTinGiangVienViewModel> FromBanTinDTOList(IEnumerable<BanTinDTO> banTinDTOList)
        {
            List<BanTinGiangVienViewModel> banTinList = new List<BanTinGiangVienViewModel>();
            foreach (BanTinDTO banTinDTO in banTinDTOList)
            {
                banTinList.Add(BanTinGiangVienViewModel.FromBanTinDTO(banTinDTO));
            }
            return banTinList.AsEnumerable();
        }
    }
}